package com.bjsdzk.collector.config;

import com.alibaba.dubbo.rpc.Invoker;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;

import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.dubbo.rpc.RpcResult;

import lombok.Setter;


public class DubboFilter implements Filter {
	
	private static final Logger logger = LoggerFactory.getLogger(DubboFilter.class);
	
	@Setter
    private Environment environment;
	@Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    	
//    	String[] activeProfiles = environment.getActiveProfiles();
//    	if(activeProfiles.length==1&&StringUtils.equals(activeProfiles[0], "test")) {
//    		logger.debug("test environment divide invoke");
//    		return new RpcResult();
//    	}
    	Result result = invoker.invoke(invocation);
        return result;
    }
}